//
//  SMOptionalCell.m
//  lishiminOC
//
//  Created by p2p on 16/10/12.
//  Copyright © 2016年 p2p. All rights reserved.
//

#import "SMOptionalCell.h"

@interface SMOptionalCell()
@property (nonatomic,strong)UILabel *numberTitleLabel;
@property (nonatomic,strong)UILabel *choosePriceLabel;
@property (nonatomic,strong)UILabel *newestPriceLabel;
@property (nonatomic,strong)SMRotateLabel *rotateLabel;
@property (nonatomic,strong)UIView *intervalView;

@end
@implementation SMOptionalCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupView];
    }
    return self;
}

- (void)setDataInTheCellWith:(NSArray *)dataArray{
    self.numberTitleLabel.text = dataArray[0];
    self.rotateLabel.text = dataArray[1];
    self.choosePriceLabel.text = dataArray[2];
    self.newestPriceLabel.text = dataArray[3];
}

- (void)setupView{
    UILabel *numberTitleLabel = [[UILabel alloc]init];
    numberTitleLabel.textColor = [UIColor redColor];
    numberTitleLabel.font = [UIFont systemFontOfSize:14];
    numberTitleLabel.textAlignment =  NSTextAlignmentLeft;
    self.numberTitleLabel = numberTitleLabel;
    [self addSubview:numberTitleLabel];
    
    
//    SMRotateLabel *rotateLabel = [[SMRotateLabel alloc]init];
//    rotateLabel.frame = CGRectMake(0, 64, 100, 50);
//    rotateLabel.backgroundColor = [UIColor grayColor];
//    rotateLabel.textColor = [UIColor redColor];
//    rotateLabel.repeatCount = 0;
//    rotateLabel.speed = UBFlashCtntSpeedVerySlow;
//    rotateLabel.text = @"wojiushikankanzhegeweishenemyizhibuxingne";
//    self.rotateLabel = rotateLabel;
//    
    
    SMRotateLabel * rotateLabel = [[SMRotateLabel alloc]init];
    rotateLabel.textColor = [UIColor redColor];
    rotateLabel.backgroundColor = [UIColor whiteColor];
    rotateLabel.frame = CGRectMake(15, 26, 100, 30);
    rotateLabel.speed = UBFlashCtntSpeedSlow;
    rotateLabel.repeatCount = 0;
    self.rotateLabel = rotateLabel;
    [self addSubview:rotateLabel];
    
    UILabel *choosePriceLabel = [[UILabel alloc]init];
    choosePriceLabel.textColor = [UIColor redColor];
    choosePriceLabel.font = [UIFont systemFontOfSize:14];
    choosePriceLabel.textAlignment =  NSTextAlignmentLeft;
    self.choosePriceLabel = choosePriceLabel;
    [self addSubview:choosePriceLabel];
    
    UILabel *newestPriceLabel = [[UILabel alloc]init];
    newestPriceLabel.textColor = [UIColor redColor];
    newestPriceLabel.font = [UIFont systemFontOfSize:14];
    newestPriceLabel.textAlignment =  NSTextAlignmentRight;
    self.newestPriceLabel = newestPriceLabel;
    [self addSubview:newestPriceLabel];
    
    UIView *intervalView = [[UIView alloc]init];
    intervalView.backgroundColor = [UIColor redColor];
    self.intervalView = intervalView;
    [self addSubview:intervalView];
}

- (void)layoutSubviews{
    __weak __typeof(&*self)weakSelf = self;

    
    [self.numberTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mas_left).with.offset(15);
        make.top.equalTo(weakSelf.mas_top).with.offset(3);
        make.width.mas_equalTo(@100);
        make.height.mas_equalTo(@20);;
    }];
    
    [self.choosePriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.rotateLabel.mas_right).with.offset(4);
        make.top.equalTo(weakSelf.mas_top).with.offset(5);
        make.bottom.equalTo(weakSelf.mas_bottom).with.offset(-5);
        make.right.equalTo(weakSelf.newestPriceLabel.mas_left);
        make.width.equalTo(weakSelf.newestPriceLabel);
    }];
    
    [self.newestPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.choosePriceLabel.mas_right);
        make.top.equalTo(weakSelf.mas_top).with.offset(5);
        make.bottom.equalTo(weakSelf.mas_bottom).with.offset(-5);
        make.right.equalTo(weakSelf.mas_right).with.offset(-15);
        make.width.equalTo(weakSelf.choosePriceLabel);
    }];
    
    [self.intervalView mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.left.equalTo(weakSelf.mas_left);
        make.bottom.equalTo(weakSelf.mas_bottom);
        make.right.equalTo(weakSelf.mas_right);
        make.height.mas_equalTo(@1);
    }];
    
    
}
@end
